package com.pug.web.pay;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pug.annotation.EnableNoToken;
import com.pug.pojo.KssUser;
import com.pug.threadlocal.UserThreadLocal;
import com.pug.vo.OrderPayVo;
import com.pug.web.BaseController;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageDeliveryMode;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * Author: lqm
 * create: 2022/4/10 17:08
 * Lover: lqx
 *
 * @see
 */
@RestController
public class WeiXinPay extends BaseController {
    @Resource
    RabbitTemplate rabbitTemplate;
    @Resource
    AlipayUtil alipayUtil;
    @PostMapping("/weixinpay")
    @EnableNoToken(true)
    public int weiXinPay(@RequestBody OrderPayVo orderPayVo){
        //支付订单
        //产生一个订单号
        String order_number=UUID.randomUUID().toString();
        String text = alipayUtil.pay(order_number, "100", "南昌大酒店");
        System.out.println(text);
        return  1;
    }
    //支付成功回调地址
    @GetMapping("/return")
    @EnableNoToken(true)
    public void aliPayReturn(String out_trade_no){
        KssUser kssUser = UserThreadLocal.get();
        String query=alipayUtil.query(out_trade_no);
        //如果支付成功，直接mq异步保存订单信息
    }
}
